package labReport.experiment1;

public class SelectArray {
    static void show(int max, int min) {
        System.out.println("最大值 = " + max);
        System.out.println("最小值 = " + min);
    }

    public static void main(String[] args) {
        int[] array = new int[]{5, 10, -8, -2, -500, 50, 200};
        int max = array[0], min = array[0];
        for (int i = 1; i < array.length; i++) {
            if (array[i] > max) {
                max = array[i];
            } else if (array[i] < min) {
                min = array[i];
            }
        }
        show(max, min);
    }
}